let idcode = (string) => {
	let weight_factor = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
	let check_code = ['1', '0', 'X' , '9', '8', '7', '6', '5', '4', '3', '2'];
	let code = string + "";
	let last = string[17];
	let seventeen = code.substring(0,17);
	let arr = seventeen.split("");
	let len = arr.length;
	var num = 0;
	for(var i = 0; i < len; i++){
		num = num + arr[i] * weight_factor[i];
	}
	let resisue = num%11;
	let last_no = check_code[resisue];
	let idcard_patter = /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/;
	let format = idcard_patter.test(string);
	return last === last_no && format ? true : false;
}
export default idcode